'use strict';

/**
 * @ngdoc directive
 * @name horizonApp.directive:myNav
 * @description
 * # myNav
 */
angular.module('routeApp')
  .directive('myNav', function () {
    return {
      templateUrl: '/static/views/base/nav.html',
      restrict: 'E',
      replace: true,
      scope: {
         list: '='
      },
      controller: function ($scope, $element, $attrs) {
//          var menu = ['instances', 'networks', 'eips', 'security_groups', 'keypairs' , 'images', 'histories', 'monitor', 'qos', 'flavors', 'tenants','users','domains','websites','assets','loadbalancers','gcache','tickets'];
//          console.log(urls.indexOf('instances'));
//          var directs = {instances:true};
//          angular.forEach(urls, function(url){
//            if(directs[url]){
//                $scope.selectedName = 'Instances';
//                console.log($scope.selectedName);
//            }
//          });
          $scope.selectItem = function(menuItem){
              if($scope.$root.isloading)return;
              if ($scope.$root.selectedNode)
                  $scope.$root.selectedNode.selected = 0;
              menuItem.selected = 1;
              $scope.$root.selectedNode = menuItem;
          }
      }
    };
  });
